<template>
    <web-view :src="src" @message="bindmessage" @loaded="bindload" @error="binderror"></web-view>
	<!-- <web-view src="https://static-mp-3f981e45-5839-48bc-b86a-fed5c9e83f3c.next.bspapp.com/cs/index.html" @message="bindmessage" @loaded="bindload" @error="binderror"></web-view> -->
</template>

<script>
export default {
    components: {
    },
    data() {
        return {
           src:''
        };
    },
	onLoad(options){
		let href = 'http://172.16.88.57:8080/h5/jw/#/pages/my/my?token=eyJhbGciOiJIUzI1NiJ9.eyJzZWxsZXJJZCI6MzcsIm9ubGluZU1hcmsiOiIxNjk0NjAwNzY1NTU2IiwiaXNMZWFndWVyIjoxLCJ0eXBlIjoiMyIsImV4cCI6MTcyNjIyMzE2NSwicGhvbmVObyI6IjEzMjY3NzMxOTQxIiwibWVtYmVySWQiOjE0OTExNH0.Cyoh4IyXG4VJUlsofZC8TqaOsjkCVs1y58jI1P-w-zE&openId=oJEug5SxbuUBp-QLId0w5rrjbpoM'
		if(options.code){
			href += `&code=${options.code}`
		}
		this.src = href
		console.log(this.src)
	},
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {},
	methods:{
		bindmessage(e){
			console.log(e,'接收的数据哈哈')
			let datas = e.detail.data 
			datas.forEach(data =>{
				if(data.type == 'pay'){
					this.requestPayment(data.payData)
				}
			})
		},
		bindload(e){
			console.log(e,'加载完成')
		},
		binderror(e){},
		// 微信支付
		requestPayment(data){
			uni.requestPayment({
				timeStamp: data.timeStamp + '',
				nonceStr: data.nonceStr,
				package: data.package,
				signType: data.signType || 'MD5',
				paySign: data.paySign,
				success: function (res) {
					console.log('success:' + JSON.stringify(res)); 
				},
				complete(){
					console.log('执行completecomplete')
					uni.navigateTo({
						url:'/pages/web/web?orderNo=' + data.orderNo
					})
				},
				fail: function (err) {
				}
			});
		}
	}
};
</script>
<style lang="less">

</style>
